<template>
  <div class="main">
    <div class="content">
      <div class="content_form">
        <el-form ref="form" :model="form" label-width="140px" class="form_item" :rules="rules">
          <el-row :gutter="24">
            <el-col :span="13">
              <el-form-item label="公告标题" prop="title">
                <el-input v-model="form.title"></el-input>
              </el-form-item>
            </el-col>
<!--            <el-col :span="13">
              <el-form-item label="创建时间" prop="createTime">
              <el-date-picker
                v-model="form.createTime"
                type="datetime"
                placeholder="选择日期时间">
              </el-date-picker>
              </el-form-item>
            </el-col> -->
            <el-col :span="13">
              <el-form-item label="发布部门" prop="pushDept" style="height:150px;overflow-y:scroll;">
                <el-tree :data="data" 
                v-model="form.pushDept"
                show-checkbox
						   node-key="id"
						   ref="tree_modify"
						   :expand-on-click-node="false" 
                @check-change="handleNodeClick"></el-tree>
                <!-- <el-input ></el-input> -->
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公告内容" prop="notices">
                <el-input v-model="form.notices"  type="textarea"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="是否隐藏或显示" prop="isShow">
              <el-radio v-model="form.isShow" label="0">显示</el-radio>
              <el-radio v-model="form.isShow" label="1" >隐藏</el-radio>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import { getToken, setToken, removeToken } from '@/utils/auth';
import { addNotice,roleDeptTreeselect1s} from '@/api/user';
export default {
    components: {},
    data() {
        return {
            engineering: '',
            engineeringTypeOption: [],
            form: {
                title: '',
                createTime: '',
                auditStatus: '',
                pushDept: '',
                notices: '',
                isShow:'',
                id:''
            },
            data:[],
            id:'',
            rules: {
                password: [{ required: true, message: '请填写内容', trigger: 'blur' }]
            }
        };
    },
    created() {
        roleDeptTreeselect1s()
            .then(response => {
                if (response.data.code == 200) {
                    this.data = response.data.depts;
                    consolwe.log(response.data)
                } else {
                }
            })
            .catch(() => {
            });
    },
    methods: {
       handleNodeClick(id) {
			    console.log("我是那个点击的数",id.id);
          var deptId=id.id
          this.id = deptId
					this.roleDeptTreeselect1s(deptId)
            },
          roleDeptTreeselect1s(deptId){
					   
					   var params_list={
						   deptId:deptId
             }
				   },
        // 保存
        addSave() {
            var params_one = {
                title: this.form.title,
                isShow:this.form.isShow,
                createTime: this.form.createTime,
                pushDept: this.id,
                notices: this.form.notices
            };
            console.log(params_one)
            addNotice(params_one)
                .then(response => {
                    this.$emit('closeModal', false);
                })
                .catch(() => {
                    // this.loading = false
                    // this.$message.error(response.data.msg)
                });
        }
    },
};
</script>
<style scoped>
</style>